#ifndef TICKET_H
#define TICKET_H

#include <string.h>
#include "time.h"
#include "order.h"
#include <vector>

using std::string;
using std::vector;

class OrderList;

class Ticket{
private:
    string code;      //车次
    string departure; //始发站
    string arrival;   //终点站
    Date dprtime;     //始发时间
    Date arvtime;     //到站时间
    int price;        //价格
    int remain;       //余票
public:
    Ticket(const string& _code, const string& _departure, 
    const string& _arrival, const Date& _dprtime, const Date&  _arvtime, 
    const int _price, const int _remain);
    Ticket();

    string getCode() const { return code; }
    string getDeparture() const { return departure; }
    string getArrival() const { return arrival;}
    Date getDprtime() const { return dprtime; }
    Date getArvtime() const { return arvtime; }
    int getPrice() const { return price; }
    int getRemain() const { return remain; }

    void setDeparture(const string& _departure) { departure = _departure; }
    void setArrival(const string& _arrival) { arrival = _arrival; }
    void setDprtime(const Date& _dprtime) { dprtime = _dprtime; }
    void setArvtime(const Date& _arvtime) { arvtime = _arvtime; }
    void setPrice(const int& _price) { price = _price; }
    void setRemain(const int& _remain) { remain = _remain; }


    void showTicketInline();  //打印车票信息
    void showTicketInblock();


};

class TicketList{
private:
    vector<Ticket> tickets;

public:
    //增删
    void addTicket();
    void addTicket(const Ticket& ticket);
    bool removeTicket(); //仅通过车次删除
    bool modifyTicket(); //添加修改函数声明
       
    //查
    Ticket* codeSearch(const string& input);   
    TicketList dprSearch(const string& input); //需要再创建一个vector暂存符合始发站的车票
    TicketList arvSearch(const string& input); 

    bool bookTicket(OrderList& oManager);     //通过车次购买. 该函数可以访问TicketList中的链表, 不需要第二个参数
    
    void showAllTickets();   //将链表中的车票信息显示在界面上
    bool isEmpty();

    void saveTickets2File();
    void loadTicketsFromFile();
};

#endif